<?php
namespace app\admin\logic;

use app\admin\validate\BaseValidate;

class BaseLogic
{
    public $result = false;
    public $err;
    protected $_param = [];
    public function __construct($param = null)
    {
        $this->_param = $param;
    }
    public function del(BaseValidate $validate){
        if($validate->validate($this->_param,__FUNCTION__) === false){
            $this->result = false;
            $this->err = $validate->getError();
            return false;
        }
        return $this->_after_del_validate();
    }
    public function update(BaseValidate $validate){
        if($validate->validate($this->_param,__FUNCTION__) === false){
            $this->result = false;
            $this->err = $validate->getError();
            return false;
        }
        return $this->_after_update_validate();
    }
    public function add(BaseValidate $validate){
        if($validate->validate($this->_param,__FUNCTION__) === false){
            $this->result = false;
            $this->err = $validate->getError();
            return false;
        }
        return $this->_after_add_validate();
    }
    protected function _after_del_validate(){
        return true;
    }
    protected function _after_update_validate(){
        return true;
    }
    protected function _after_add_validate(){
        return true;
    }
}
